package com.tsu.mall.common.mapper;

import com.tsu.mall.common.VO.DetailInfoVo;
import com.tsu.mall.common.entity.BillDetail;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author tttttt
 * @since 2023-04-08
 */
public interface BillDetailMapper extends BaseMapper<BillDetail> {


    @Update("update bill set status='已支付' where code=#{outTradeNo}")
    void updateStatus(String outTradeNo);

    @Select("select id from bill where code=#{outTradeNo}")
    Integer doSelectByCode(String outTradeNo);

    @Update("update bill_detail set status='已支付' where bill_id=#{billId}")
    void updateBillDetailStatus(Integer billId);

    @Select("select wares.wares_name,bill_detail.member_wares_version,bill_detail.member_wares_version,bill_detail.member_wares_color\n" +
            ",bill_detail.`status`\n" +
            "from bill_detail\n" +
            "inner join wares on wares.id=bill_detail.wares_id\n" +
            "where bill_detail.bill_id=#{billId}")
    List<DetailInfoVo> selectBillDetail(Integer billId);
}
